#include<iostream>

using namespace std;

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        long long x, y;
        cin >> x >> y;
        for (int i = 0; i <= 60; i++)
        {
            long long nx = (x >> i);
            if (nx == y)
            {
                cout << i << endl;
                break;
            }
            else if (nx < y && (nx & y) == nx)
            {
                cout << i + 1 << endl;
                break;
            }
        }
    }
    return 0;
}